import {getAddress, setAddress} from "@/utils/authAddress";
import {getUserInfo, setUserInfo} from "@/utils/authUserInfo";
import {loginAPI} from "@/api/userApi";

const actions = {
    async login(context, params) {
        const result = await loginAPI(params)
        console.log(result)
    }
}
const mutations = {
    updateAddress(state, address) {
        state.address = address
        setAddress(address)
    },
    updateUserInfo(state, user) {
        state.userInfo = user.userInfo
        setUserInfo(user.userInfo)
    }
}
const state = () => {
    return {
        address: getAddress(),
        token: "",
        userInfo: getUserInfo()
    }
}
const getters = {
    fullAddress(state) {
        return state.address.cityName + state.address.countyName + state.address.detailInfo
    },
}

export default {
    namespaced: true,
    actions,
    mutations,
    state,
    getters
}
